package cn.edu.sgu.www.pms.service.impl;

import cn.edu.sgu.www.pms.entity.TableField;
import cn.edu.sgu.www.pms.mapper.TableFieldMapper;
import cn.edu.sgu.www.pms.service.TableFieldService;
import cn.edu.sgu.www.pms.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 沐雨橙风ιε
 * @version 1.0
 */
@Service
public class TableFieldServiceImpl implements TableFieldService {

    private final TableFieldMapper tableFieldMapper;

    @Autowired
    public TableFieldServiceImpl(TableFieldMapper tableFieldMapper) {
        this.tableFieldMapper = tableFieldMapper;
    }

    @Override
    public List<TableField> selectFields(String tableName) {
        if (StringUtils.isEmpty(tableName)) {
            return new ArrayList<>();
        }

        return tableFieldMapper.selectByTableName(tableName);
    }

}